<!--
 *  Description: Administrator sends an email to all members.
 -->

<%@ include file="declarations.jsp" %>
<jsp:useBean id="emailBean" scope="session" class="com.asaga.tools.Email_DBImpl" />
<jsp:setProperty name="emailBean" property="*" />
<%@page import="java.sql.*, java.io.*, java.util.*, java.net.*"%>

<!-- IMPORT from Java Mail API -->
<%@page import="javax.mail.*, javax.mail.internet.*, javax.activation.*"%>

<% String emailFrom = "";
   String emailTitle = "";
   String emailBody = "";
   String emailSign = ""; %>

<html>
    <%@ include file="header.jsp" %>
        <!-- VERIFY the blank of sender's email address, subject, contents of email  -->
        <script language="javascript">
        function send(){

          <!-- VERIFY the blank of sender's email address -->
          var str = document.allUsers.from.value
          if (str == ""){
                alert("Please type sender's email address")
                document.allUsers.from.focus()
                return false
          }

          <!-- VERIFY the blank of subject -->
          var str = document.allUsers.mailtitle.value
          if (str == ""){
                alert("Please type subject of email")
                document.allUsers.mailtitle.focus()
                return false
          }

          <!-- VERIFY the blank of contents of email  -->
          var str = document.allUsers.mailbody.value
          if (str == ""){
                alert("Please type contents")
                document.allUsers.mailbody.focus()
                return false
          }

                var mail = allUsers.from.value;
                if(checkMail(mail) == false) 
                return false;

                return confirm("Are you sure you want to send these email?");
        }
        </script>
    <body>
        <div id="container">
            <%@ include file="topNav.jsp" %>
            <%@ include file="leftside.jsp" %>
            <%@ include file="rightside.jsp" %>
        <div id="content">
<table border="0" width="561">
    <tr>
        <td width="555">
            <p><font>&nbsp;</font><font face="Verdana" size="3"><b>Please Write Group Email</b></font></p>
        </td>
    </tr>
    <tr>
        <td width="555">
            <p>
	     <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr><td width="926">      

             <table border="0" width="80%" align="center" cellpadding="0" cellspacing="0">
             <tr><td>

                  <!-- START email form -->
                  <form name="allUsers" action="AutismSiteMasterController" method="get" onSubmit="return send();">
                    <table border="0" width="100%" align="center" cellpadding="4" cellspacing="1">
                        
                        <tr><td align="right"><font face="Verdana" size="2">FROM</font></td>
                        <td><input type="text" name="from" id="from" size="45" value=<%=emailFrom%>></td>
                        </tr>

                        <tr><td align="right"><font face="Verdana" size="2">SUBJECT</font></td>
                        <td><input type="text" name="title" id="title" size="45" value=<%=emailTitle%>></td>
                        </tr>

                        <tr><td align="right"><font face="Verdana" size="2">CONTENTS</font></td>
                        <td><textarea name="body" id="body" cols="50" rows="15" value=<%=emailBody%>></textarea></td>
                        </tr>

                        <tr><td align="right"><font face="Verdana" size="2">SIGNATURE</font></td>
                        <td><font><textarea name="sign" id="sign" cols="45" rows="6" value=<%=emailSign%>></textarea></font></td>
                        </tr>
                    </table>

                    <table width="100%" border="0" cellpadding="0" cellspacing="0">
                        <tr><td  align="center">&nbsp;</td></tr>
                        <tr><td  align="center">
                        <input type="submit" name="action" value="Email Users">
                        <input type="reset" value="Reset">
                        </td></tr>
                    </table>
                </form>
                <!-- END email form -->
            </td></tr>
            </table>
                
           </td></tr>                  
        </table>	    
        </td></tr>
</table>
            </div>
            <%@ include file="footer.jsp" %>
        </div>    
</body>
</html>
